package com.xxx.listener;

import com.xxx.service.ZooKeeperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * zookeeper节点变化监听器
 */
@Component
public class ZookeeperListener implements CommandLineRunner {

    @Autowired
    private ZooKeeperService zooKeeperService;

    @Override
    public void run(String... args) throws Exception {
        String path = "/test-node";

        // 监听节点变化
        zooKeeperService.watchNode(path);
    }

}
